﻿@using RuoVea.ExEnum
@using RuoVea.ExSugar
@using RuoVea.OmiApi.Article.Entitys
@using RuoVea.OmiApi.Article.Service
@using RuoVea.OmiApi.Article.Service.Dto
@using RuoVea.OmiApi.Dict.Entitys
@using RuoVea.OmiApi.Dict.Service
@using RuoVea.OmiApi.Dict.Service.Dto
@inject SysDictTypeService sysDictTypService;
@inject SugarRepository<ArtCategory> _thisRepository;
@{
    //网站信息
    SysDictType webInfo = await sysDictTypService.GetTypeAndDataByCodeAsync("WEBINFO");
    var title = webInfo?.Children?.Where(x => x.Code == "title")?.Select(x => x.Value)?.FirstOrDefault();
    var footer = webInfo?.Children?.Where(x => x.Code == "footer")?.Select(x => x.Value)?.FirstOrDefault();
    var them = webInfo?.Children?.Where(x => x.Code == "them")?.Select(x => x.Value)?.FirstOrDefault();

    SysDictType me = await sysDictTypService.GetTypeAndDataByCodeAsync("me");
    var name = me?.Children.Where(x => x.Code == "name").Select(x => x.Value).FirstOrDefault();
    var job = me?.Children.Where(x => x.Code == "job").Select(x => x.Value).FirstOrDefault();

    SysDictType avatar = await sysDictTypService.GetTypeAndDataByCodeAsync("ATAVAR");
    //基本信息
    SysDictType profile = await sysDictTypService.GetTypeAndDataByCodeAsync("PROFILE");
    //联系方式
    SysDictType contact = await sysDictTypService.GetTypeAndDataByCodeAsync("CONTACT");
    //技能点
    SysDictType skill = await sysDictTypService.GetTypeAndDataByCodeAsync("SKILL");
    //二维码
    SysDictType qrcode = await sysDictTypService.GetTypeAndDataByCodeAsync("QRCODE");
    //技术栈
    SysDictType stack = await sysDictTypService.GetTypeAndDataByCodeAsync("STACK");
    //侧栏
    SysDictType aside = await sysDictTypService.GetTypeAndDataByCodeAsync("ASIDE");

    var superContents = await (from u in _thisRepository.AsQueryable().Includes(u => u.Articles) orderby u.Sort select u).ToListAsync();
}
<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="email=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="renderer" content="webkit">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-title" content="@Html.Raw(title)" />
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <title>@Html.Raw(title)</title>
    <link rel="stylesheet" href="~/lib/assets/css/typo.css">
    <style>
        a {color: @(Html.Raw(them));}
        aside ul li {background: @(Html.Raw(them));}
        .info-content {margin-top: 10px;}</style>
    <link rel="stylesheet" href="~/lib/assets/css/font-awesome.min.css">
    <link rel="stylesheet" href="~/lib/assets/css/index.css">

</head>
<body>
    <header class="header"></header>
    <article class="container">
        <section class="side" id="side">
            <!-- 个人肖像 -->
            <section class="me">
                <section class="portrait">
                    <!-- 头像照片 -->
                    <img class="avatar" src="@avatar?.Children?.Select(x => x.ExtData)?.FirstOrDefault()">
                </section>
                <h1 class="name">@Html.Raw(name)</h1>
                <h4 class="info-job">@Html.Raw(job)</h4>
            </section>
            <!-- 基本信息 -->
            <section class="profile info-unit">
                <h2>
                    <i class="fa fa-user" aria-hidden="true"></i>@Html.Raw(profile?.Name)
                </h2>
                <hr />
                <ul>
                    @foreach (var item in profile?.Children?.OrderBy(x => x.Sort)?.ToList() ?? new List<SysDictValue>())
                    {
                        <li><label>@Html.Raw(item.Label)</label><span>@Html.Raw(item.Value)</span> </li>
                    }
                </ul>
            </section>
            <!-- 联系方式 -->
            <section class="contact info-unit">
                <h2>
                    <i class="fa fa-phone" aria-hidden="true"></i>@Html.Raw(contact?.Name)
                </h2>
                <hr />
                <ul>
                    @foreach (var item in contact?.Children.OrderBy(x => x.Sort)?.ToList() ?? new List<SysDictValue>())
                    {
                        <li>
                            <label>@Html.Raw(item.Label)</label>
                            <a href="@item.Value" target="_blank">@Html.Raw(item.Value)</a>
                        </li>
                    }
                </ul>
            </section>

            <!-- 技能点 -->
            <section class="skill info-unit">
                <h2>
                    <i class="fa fa-code" aria-hidden="true"></i>@Html.Raw(skill?.Name)
                </h2>
                <hr />
                <ul>
                    @foreach (var item in skill?.Children.OrderBy(x => x.Sort)?.ToList() ?? new List<SysDictValue>())
                    {
                        <li>
                            <label>@Html.Raw(item.Label)</label>
                            <progress value="@item.Value" max="100"></progress>
                        </li>
                    }
                </ul>
            </section>
            <section class="qrcode info-unit">
                <h2><i class="fa fa-qrcode" aria-hidden="true"></i>@Html.Raw(qrcode?.Name)</h2>
                @foreach (var item in qrcode?.Children.OrderBy(x => x.Sort)?.ToList() ?? new List<SysDictValue>())
                {
                    <hr />
                    <img src="@item.ExtData" style="width: 100%;" alt="">
                }

            </section>
            <!-- 技术栈 -->
            <div class="stack info-unit">
                <h2><i class="fa fa-code" aria-hidden="true"></i>@Html.Raw(stack?.Name)</h2>
                <hr />
                <ul>
                    @foreach (var item in stack?.Children.OrderBy(x => x.Sort)?.ToList() ?? new List<SysDictValue>())
                    {
                        <li>
                            <label>@Html.Raw(item.Label)</label>
                            <span>@Html.Raw(item.Value)</span>
                        </li>
                    }
                </ul>
            </div>
        </section>
        <section class="main">
            @foreach (var item in superContents)
            {
                <section class="@Html.Raw(item.Code) info-unit">
                    <h2>
                        <i class="fa @Html.Raw(item.Code)" aria-hidden="true"></i>@Html.Raw(item.Name)
                    </h2>
                    <hr />
                    <ul>
                        @foreach (var subItem in item.Articles.OrderByDescending(x => x.Sort).ToList())
                        {
                            <li>
                                <h3>
                                    <span>@Html.Raw(subItem.Title)</span>
                                    <time>@Html.Raw(subItem.Subtitle)</time>
                                </h3>
                                <div class="info-content">
                                    @Html.Raw(subItem.Content)
                                </div>
                            </li>
                        }
                    </ul>
                </section>
            }
        </section>
    </article>
    <footer class="footer">
        <p>@Html.Raw(footer)</p>
    </footer>
    <!-- 侧栏 -->
    <aside>
        <ul>
            @foreach (var item in aside?.Children?.OrderBy(x => x.Sort)?.ToList() ??new List<SysDictValue>())
            {
                <li><a href="@item.Value" target="_blank">@Html.Raw(item.Label)</a></li>
            }
        </ul>
    </aside>
</body>
</html>